﻿package mortal.game.view.task
{
    import com.greensock.*;
    import com.mui.controls.*;
    import com.mui.display.*;
    import com.mui.manager.*;
    import com.mui.utils.*;
    import extend.language.*;
    import flash.events.*;
    import mortal.component.gLinkText.*;
    import mortal.game.events.*;
    import mortal.game.manager.*;
    import mortal.game.mvc.*;
    import mortal.game.resource.*;
    import mortal.game.view.best.panel.*;
    import mortal.game.view.common.*;
    import mortal.game.view.copy.*;
    import mortal.game.view.hardware.*;
    import mortal.game.view.task.view.render.*;
    import mortal.game.view.task.view.track.*;
    import mortal.mvc.core.*;

    public class TaskTrackModuleNew extends View
    {
        private var _bodyContainer:GSprite;
        private var _bg:ScaleBitmap;
        private var _btnAdd:GLoadedButton;
        private var _bmpTitle:GBitmap;
        private var _spRWZZ:ToolTipSprite;
        private var _btnExpandBg:GLoadedButton;
        private var _btnExpand:GLoadedButton;
        private var _btnUnExpand:GLoadedButton;
        private var _bmpRWZZ:GBitmap;
        private var _tasks:TaskTrackContainer;
        private var _line:GBitmap;
        private var _tween:TimelineLite;
        private var _isExpanding:Boolean = true;
        public var bestInfoPanel:BestNewInfoPanel;
        public var kaCkTxt:GButton;
        private var _kaState:Boolean = false;

        public function TaskTrackModuleNew()
        {
            this.layer = LayerManager.uiLayer;
            mouseEnabled = false;
            return;
        }// end function

        public function get isExpanding() : Boolean
        {
            return this._isExpanding;
        }// end function

        public function get tasks() : TaskTrackContainer
        {
            return this._tasks;
        }// end function

        public function showGuideArrow(param1:int, param2:int, param3:GLinkTextData, param4:Boolean, param5:Boolean = false) : void
        {
            this._tasks.showGuideArrow(param1, param2, param3, param4, param5);
            return;
        }// end function

        public function hideGuideArrow() : void
        {
            this._tasks.hideGuideArrow();
            return;
        }// end function

        public function hideTrackExceptBtn(param1:Boolean) : void
        {
            if (this.isDisposed)
            {
                return;
            }
            if (param1)
            {
                this.unExpandHandler(null);
            }
            else
            {
                this.expandHandler(null);
            }
            return;
        }// end function

        private function viewTaskModuleHandler(event:MouseEvent) : void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.TaskShowHideModule));
            return;
        }// end function

        override public function stageResize() : void
        {
            super.stageResize();
            CopyInfo_TaskTrackConnector.updateLaout();
            return;
        }// end function

        override public function show(param1:int = 0, param2:int = 0) : void
        {
            super.show(param1, param2);
            this.stageResize();
            CopyInfo_TaskTrackConnector.registerTaskTrack(this);
            return;
        }// end function

        override public function get width() : Number
        {
            return 214;
        }// end function

        private function unExpandHandler(param1 = null) : void
        {
            if (this._tween != null && this._tween.active)
            {
                this._tween.kill();
                this._tween = null;
            }
            this._tween = new TimelineLite();
            this._tween.append(TweenLite.to(this._bodyContainer, 0.2, {x:430}));
            this._tween.append(TweenLite.to(this._spRWZZ, 0.1, {x:181}));
            this._isExpanding = false;
            CopyInfo_TaskTrackConnector.updateLaout();
            return;
        }// end function

        private function expandHandler(param1 = null) : void
        {
            if (this._tween != null && this._tween.active)
            {
                this._tween.kill();
                this._tween = null;
            }
            this._tween = new TimelineLite();
            this._tween.append(TweenLite.to(this._spRWZZ, 0.1, {x:247}));
            this._tween.append(TweenLite.to(this._bodyContainer, 0.2, {x:0}));
            this._isExpanding = true;
            CopyInfo_TaskTrackConnector.updateLaout();
            return;
        }// end function

        private function onShowTip(event:MouseEvent) : void
        {
            OtherBrowserTipWindow.instance.show();
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this._isExpanding = true;
            this._bodyContainer = UICompomentPool.getUICompoment(GSprite) as GSprite;
            this._bodyContainer.mouseChildren = true;
            this._bodyContainer.mouseEnabled = true;
            this.addChild(this._bodyContainer);
            this._bg = UIFactory.bg(0, -7, 214, 340, this._bodyContainer, ImagesConst.taskTrackBg2);
            this._btnAdd = UIFactory.gLoadedButton(ImagesConst.taskTrackAdd_upSkin, 6, 6, 20, 20, this._bodyContainer);
            this._bmpTitle = UIFactory.gBitmap(ImagesConst.taskTrack_RW, 88, 9, this._bodyContainer);
            this._btnUnExpand = UIFactory.gLoadedButton(ImagesConst.taskTrackRight_upSkin, 186, 6, 20, 20, this._bodyContainer);
            this._spRWZZ = UICompomentPool.getUICompoment(ToolTipSprite) as ToolTipSprite;
            this._spRWZZ.x = 247;
            this._spRWZZ.mouseChildren = true;
            this._spRWZZ.mouseEnabled = true;
            this.addChild(this._spRWZZ);
            this._btnExpandBg = UIFactory.gLoadedButton(ImagesConst.taskTrack_upSkin, 0, 0, 35, 101, this._spRWZZ);
            this._btnExpand = UIFactory.gLoadedButton(ImagesConst.taskTrackLeft_upSkin, 11, 6, 20, 20, this._spRWZZ);
            this._bmpRWZZ = UIFactory.gBitmap(ImagesConst.taskTrack_RWZZ, 13, 29, this._spRWZZ);
            this._tasks = UICompomentPool.getUICompoment(TaskTrackContainer) as TaskTrackContainer;
            this._tasks.x = 8;
            this._tasks.y = 32;
            this._tasks.render = TaskTrackDoing;
            this._bodyContainer.addChild(this._tasks);
            this._line = UIFactory.gBitmap(ImagesConst.taskTrackDown, 0, 208, this._bodyContainer);
            this.bestInfoPanel = UIFactory.getUICompoment(BestNewInfoPanel, 2, 220, this._bodyContainer);
            this._btnAdd.configEventListener(MouseEvent.CLICK, this.viewTaskModuleHandler);
            this._btnAdd.toolTipData = Language.getString(21244);
            this._btnUnExpand.configEventListener(MouseEvent.CLICK, this.unExpandHandler);
            this._btnUnExpand.toolTipData = Language.getString(21245);
            this._spRWZZ.configEventListener(MouseEvent.CLICK, this.expandHandler);
            this._spRWZZ.toolTipData = Language.getString(21246);
            this.kaCkTxt = UIFactory.gButton(Language.getString(21247), 53, 303, 100, 30, this._bodyContainer, "GreenLinkButton");
            this.kaCkTxt.configEventListener(MouseEvent.CLICK, this.onShowTip);
            this.kaCkTxt.visible = false;
            Dispatcher.dispatchEvent(new DataEvent(EventName.BestTaskTrackModeOpen));
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            super.disposeImpl(param1);
            this._bodyContainer.dispose(param1);
            this._bodyContainer = null;
            this._bg.dispose(param1);
            this._bg = null;
            this._btnAdd.dispose(param1);
            this._btnAdd = null;
            this._bmpTitle.dispose(param1);
            this._bmpTitle = null;
            this._btnUnExpand.dispose(param1);
            this._btnUnExpand = null;
            this._spRWZZ.dispose(param1);
            this._spRWZZ = null;
            this._btnExpandBg.dispose(param1);
            this._btnExpandBg = null;
            this._btnExpand.dispose(param1);
            this._btnExpand = null;
            this._bmpRWZZ.dispose(param1);
            this._bmpRWZZ = null;
            this._tasks.dispose(param1);
            this._tasks = null;
            this._line.dispose(param1);
            this._line = null;
            this.bestInfoPanel.dispose(true);
            this.bestInfoPanel = null;
            this.kaCkTxt.dispose(param1);
            this.kaCkTxt = null;
            if (this._tween != null)
            {
                this._tween.kill();
                this._tween = null;
            }
            return;
        }// end function

        public function get kaState() : Boolean
        {
            return this._kaState;
        }// end function

        public function set kaState(param1:Boolean) : void
        {
            this._kaState = param1;
            if (this.kaCkTxt)
            {
                this.kaCkTxt.visible = this._kaState;
            }
            return;
        }// end function

    }
}
